import psutil
import os


def kill_process(process_name):  # "Excel.exe"
    pids = psutil.pids()
    for pid in pids:
        try:
            process = psutil.Process(pid)
            print("pid=%s, process name=%s" % (pid, process.name()))  # 打印所有进程ID和名字
            # 关闭Excel进程
            if process.name() == process_name:
                cmd = "taskkill /F /IM %s" % process_name
                os.system(cmd)
        except Exception as e:
            print(e)


if __name__ == "__main__":
    kill_process("KuGou.exe")